<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="client_message" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="supplierAddSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <el-button @click="gotoPage('/psi/supplychainmana/CartogramSupplier?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 添加供应商 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="分类" prop="client_class">
              <el-radio-group v-model="client_message.client_class">
                <el-radio-button label="组织">组织</el-radio-button>
                <el-radio-button label="个人">个人</el-radio-button>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="供应商条形码" prop="client_barcode">
              <el-input v-model="client_message.client_barcode" readonly />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="供应商类型" prop="client_type">
              <el-select style='width:100%' v-model="client_message.client_type">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in s_clienttype" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="供应商名称" prop="client_name">
              <el-input v-model="client_message.client_name" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="供应商等级" prop="client_rate">
              <el-select style='width:100%' v-model="client_message.client_rate">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in s_sort" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="网站地址" prop="client_net">
              <el-input v-model="client_message.client_net" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="行业" prop="client_bus">
              <el-select style='width:100%' v-model="client_message.client_bus">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in clientbus" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 电话号码 </span>
      </div>
      <div>
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 附加信息 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="client_remark">
              <el-input type="textarea" v-model="client_message.client_remark" ttparea=350></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-button @click="supplierAddSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <el-button @click="gotoPage('2CB1709D05194080B7E5E97C60257191?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'SupplierAdd',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams("&CMID5=13"),
        client_message: {
          client_class: null,
          client_barcode: null,
          client_type: null,
          client_name: null,
          client_rate: null,
          client_net: null,
          client_bus: null,
        },
        mvc_add_list: {
          client_remark: null,
        },
        s_clienttype: [],
        s_sort: [],
        clientbus: [],
        loading: false,
        rules: {
          client_name: [{
            required: true,
            message: "供应商名称不能为空",
            trigger: 'blur',
          }],
        }
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/supplychainmana/SupplierAction/supplierAdd?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      supplierAddSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/psi/supplychainmana/SupplierAction/supplierAddSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/psi/sale/SupplierDet/supplierDet?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
    },
  }
</script>
